const forge = require("node-forge");
const superagent = require("superagent");
const fs = require("fs");
var cookie = require('cookie');
let cookies = `HMF_CI=83095a5b68a71234db926f80ee8275618b8e5f4e9739b094d13386f8a2ed6743cd; CSH_DF=e+95dLZon55CCV0N3sToV+3Pr1jespeSK43aDuDIWKe9aKo/C0l0aOwTkDAyhYJMLf; cookiePolicy=Accepted; cookiePreference=Accepted; Hm_lvt_d16e4336470e6b4d88aa16ff927d7daf=1638276741,1639140260,1639140607,1639144736; Hm_lpvt_d16e4336470e6b4d88aa16ff927d7daf=1639145374; django_language=zh-cn; token=332e58a3-8257-4d8d-8210-f8fbe7beb847`//fs.readFileSync("./cookies.txt", "utf-8");
let cookieObject = cookie.parse(cookies);
console.log(cookieObject);
/* var o = {
    a(e) {
        let r = forge;
        var t = r.pki.publicKeyFromPem("-----BEGIN PUBLIC KEY-----\n MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsy4xppPDUT2eAOR5h0cyydzxtKB9O80A\n GjUT6FmDgg6CwelpnE0C2h2JQyP1gCveJs6GDwSDn20RVVpD67f//YPYErjaH/CBOxNG3k5IkW1o\n Qx04uqFNMtWvjzk0aFh2eJLsBi7Ha4elw3WySg00B8oZCL4VBay4ML9kyOAjjCj5jHCX8a2yxIMJ\n IF+EjW3kBR68IMwBvuDL45Qa0oB24vTffaSEs+hGjMTQvoCciOfti3pmEAlVc438/cBgAhK5cIMf\n IMElxYAVvmsDy0I7RCUTrajetKjX94Q+JuQUxnIHNC3IVtYsl1x0lNRtb93IhlRCkZ9djOu350eq\n hZIOXQIDAQAB\n  -----END PUBLIC KEY-----").encrypt(e, "RSA-OAEP", {
            md: r.md.sha256.create(),
            mgf1: {
                md: r.md.sha1.create()
            }
        });
        return Buffer.from(t).toString("base64")
    }
}
function a(e, t, n) {
    var a = {
        username: e,
        password: Object(o.a)(t),
        // captcha: n
    };
    return a
    // return r.a.formPost("/user/login", a)
}
let form = a('yusup64', 'Aa112211', '132') */

let body = { "startDate": "2021-12-11 00:00", "channelCode": "GENERAL", "cargoCategory": "GENERAL", "prodType": "I", "page": 1, "size": 30 }

superagent.post('https://synconhub.coscoshipping.com/api/product/client/sailing/product/list').set({
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36',
    'Cookie': cookies,
    'X-Auth-Token': cookieObject.token,
    'X-Custom-UC': '34a63109d77752d29c62dd7082fd9270',
    'Origin': 'https://synconhub.coscoshipping.com',
    'Content-Type': 'application/json;charset=UTF-8',
    'Referer': "https://synconhub.coscoshipping.com/product?tradeGroupCode=all&startDate=2021-12-11%2000%3A00&channelCode=GENERAL&cargoCategory=GENERAL&prodType=I&page=1",
    'X-Client-Timestamp': Date.now()
}).send(body).then(res => {
    console.log(res.body);
}).catch(err => {
    console.log(111, err);
})